package cn.lynu.study;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCconnect {

	public static void main(String[] args) throws Exception {

			   Class.forName("com.mysql.cj.jdbc.Driver");		       
		   	   Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/book?user=root&password=root&serverTimezone=GMT");
		   	   Statement stmt=conn.createStatement();
		   	   ResultSet rs=stmt.executeQuery("SELECT * FROM booklist");
		       System.out.println("---ISBN---\t---name---\t---price");
		   	   while(rs.next()) {
		   		 String ISBN= rs.getString("ISBN");
		   		 String name= rs.getString("name");
		   		 float price= rs.getFloat("price");
		   		
				System.out.println(ISBN+"\t\t"+ name+"\t\t"+ price);
		   	   }

	}

}
